<!--轧差排队管理申请录入页面-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      defaultEventKey="entryTable"
    ></ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      defaultEventKey="entryTable"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('detials', scope.row);
                  },
                },
                {
                  label: '排队管理',
                  visible: scope.row.totalNum > 0 && scope.row.rcvType === '05',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('queueManage', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <!-- 明细弹出框 -->
    <details-dialog ref="detailsDialog" :dictMap="dictMap" :isNets="true" :formData.sync="formData"></details-dialog>
    <!-- 排队管理弹出框 -->
    <queue-manage-dialog
      ref="queueManageDialog"
      :dictMap="dictMap"
      :pkgId="pkgId"
      @editComplete="editComplete"
    ></queue-manage-dialog>
  </div>
</template>
<script>
import { apiUrlConfig, sendApply } from "@/api/cnaps/nets/queueMng/nets_queue_manage_entry.js";
import DetailsDialog from "./components/details";
import QueueManageDialog from "./components/queueManage";
import { listPageMixin } from "@/libs/listPageMixin";

export default {
  name: "netsQueueManageEntry",
  mixins: [listPageMixin],
  components: {
    DetailsDialog,
    QueueManageDialog,
  },
  data() {
    return {
      pkgId: "",
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: ["PKG_STATUS", "PROCESSSTATUS"],
      //  明细弹框数据
      // form表单字段
      formData: {},
      showSearch: true,
      // 查询参数
      queryParams: {
        vdate: "",
        vdate1: "",
        workdate: "",
        workdate1: "",
      },
      formOptions: [],
      opButtonList: () => {
        return [
          {
            label: "发送查询申请",
            type: "primary",
            icon: "",
            // permission: "user:xxx:xxx",
            clickFun: () => {
              this.handleAction("sendApply");
            },
          },
        ];
      },
      tableBindColumns: [
        { label: `交易流水号`, prop: "id", width: "170", sortable: false },
        {
          label: `CPG日期`,
          prop: "vdate",
          sortable: false,
          type: "date",
        },
        {
          label: `工作日期`,
          prop: "workdate",
          sortable: false,
          type: "date",
        },
        { label: `被查询行`, prop: "inqStBrno", width: "160", sortable: false },
        {
          label: `排队业务数目`,
          prop: "totalNum",
          width: "160",
          sortable: false,
        },
        {
          label: `申请时间`,
          prop: "sndTime",
          width: "160",
          sortable: false,
          type: "date",
        },
        {
          label: `通讯状态`,
          prop: "rcvType",
          width: "100",
          dictCode: "PKG_STATUS",
          sortable: false,
        },
        {
          label: `中心状态`,
          prop: "procStatus",
          dictCode: "PROCESSSTATUS",
          sortable: false,
        },
      ],
    };
  },
  mounted() {
    this.formOptions = [
      {
        type: "dates",
        nameObj: {
          startTimeName: "vdate",
          endTimeName: "vdate1",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate1",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
    ];
  },
  methods: {
    editComplete(state) {
      if (state == true) {
        this.$refs.dataTable.doQuery();
      }
    },
    /** 明细按钮操作 */
    toEdit(row) {
      this.$refs.detailsDialog.show();
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "sendApply":
          // 发送查询申请
          let sendData = {
            vdate: this.queryParams.vdate,
            vdate1: this.queryParams.vdate1,
            workdate: this.queryParams.workdate,
            workdate1: this.queryParams.workdate1,
          };
          sendApply(sendData).then((res) => {
            console.log(res, "发送成功！");
            this.msgSuccess("发送成功！");
            this.$refs.dataTable.doQuery();
          });
          break;
        case "detials":
          // 明细信息
          this.formData = _.clone(row);
          this.$refs.detailsDialog.show();
          break;
        case "queueManage":
          // 排队管理
          this.pkgId = row.pkgId;
          this.$refs.queueManageDialog.show();
          break;
      }
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
